<?php
include_once("php/dbconfig.php");
include_once("php/functions.php");

include_once("admin/cfg/user.php");
$gUid = new CalendarUser();
$login_admin_id = $gUid->isAdminUser();
$login_authenticated_id = $gUid->isAuthenticatedUser();

function getCalendarByRange($id) {
    try {
        $db = new DBConnection();
        $db->getConnection();
        $sql = "SELECT  `event`.`eid`, `event`.`subject`,`event`.`start_time`,`event`.`end_time`, 
                    `event`.`is_allday_event`,`event`.`color`,`event`.`detail_url`,`event`.`festival`,
                    `event`.`description`,`event`.`picture_paths`,`event`.`vid`,`event`.`etid`,
                    `event`.`commercial_control`,`event`.`click_window_control`,
                    `event`.`uid`,`venue`.`telephones`,`venue`.`urls`,`venue`.`address_zh_hk`,
                    `venue`.`contact_person`,`venue`.`cid`,`venue`.`name_zh_hk` AS `vname_zh_hk`
            FROM `event` INNER JOIN `venue` ON `event`.`vid` = `venue`.`vid`
            INNER JOIN `event_type` ON `event`.`etid` = `event_type`.`etid`
            WHERE `event`.`eid` = " . $id;
        $sql .= " AND `event_type`.`delete_flag` = 0 AND `venue`.`delete_flag` = 0 ";
        $handle = mysql_query($sql);
        //echo $sql;
        $row = mysql_fetch_object($handle);
    } catch (Exception $e) {
        
    }
    return $row;
}

if ($_GET["id"]) {
    $event = getCalendarByRange($_GET["id"]);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >

    <head>    
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">   
<!--            header('Content-type:text/javascript;charset=UTF-8');-->
            <title>Calendar Details</title>    
            <link href="css/subwindows.css" rel="stylesheet" type="text/css" />       
            <link href="css/dp.css" rel="stylesheet" />    
            <link href="css/dropdown.css" rel="stylesheet" />    
            <link href="css/colorselect.css" rel="stylesheet" />   

            <script src="src/jquery.js" type="text/javascript"></script>    
            <script src="src/Plugins/Common.js" type="text/javascript"></script>    

            <!--    jace 2011826 start-->
            <!--    <script src="src/Plugins/jquery.form.js" type="text/javascript"></script>    -->
            <script src="src/Plugins/jquery.form.2.84.js" type="text/javascript"></script>    
            <!--    jace 2011826 end-->    
            <script src="src/Plugins/jquery.validate.js" type="text/javascript"></script>     
            <script src="src/Plugins/datepicker_lang_HK.js" type="text/javascript"></script>        
            <script src="src/Plugins/jquery.datepicker.js" type="text/javascript"></script>     
            <script src="src/Plugins/jquery.dropdown.js" type="text/javascript"></script>     
            <script src="src/Plugins/jquery.colorselect.js" type="text/javascript"></script>    

            <script type="text/javascript">
 function checkStEt(sd,ed,st,et)
    {
        if(sd==""||ed==""){return false;}
        sd_t=stringtodate(sd,st);
        ed_t=stringtodate(ed,et);
        if(sd_t>ed_t)
        {
            return true;
            //alert("開始日期不能大於結束日期");
        }
        else
        {
            return false;
            //$("#stpartdate").val(sd);
        }
    }
    function stringtodate(datestr,timestr) {
        try
        {
            //time:   00:00
            var arrs = datestr.split(i18n.datepicker.dateformat.separator);
            var year = parseInt(arrs[i18n.datepicker.dateformat.year_index],10);
            var month = parseInt(arrs[i18n.datepicker.dateformat.month_index],10) - 1;
            var day = parseInt(arrs[i18n.datepicker.dateformat.day_index],10);
                            
            var arrt = timestr.split(":");
            var hour=parseInt(arrt[0],10);
            var min=parseInt(arrt[1],10);
            var sec=0;
                            
            return new Date(year, month, day,hour,min,sec);
        }
        catch(e)
        {
            return null;
        }
    }
                     
            function checkDescriptionValid()
            {
                var control_len=1000;//與數據字段寬度一致
                var a = $("#Description").val();
                if(getLength(a) > control_len)
                {
                    return "輸入的內容長度不能超過　"+control_len+"　個字符!";
                }
                else
                {
                    return "";
                }
        }
        function getLength(str) { 
            var len = str.length; 
            var reLen = 0; 
            for (var i = 0; i < len; i++) {        
                if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) { 
                    // 全角    
                    reLen += 2; 
                } else { 
                    reLen++; 
                } 
            } 
    return reLen;    
} 
if (!DateAdd || typeof (DateDiff) != "function") {
    var DateAdd = function(interval, number, idate) {
        number = parseInt(number);
        var date;
        if (typeof (idate) == "string") {
            date = idate.split(/\D/);
            eval("var date = new Date(" + date.join(",") + ")");
        }
        if (typeof (idate) == "object") {
            date = new Date(idate.toString());
        }
        switch (interval) {
            case "y": date.setFullYear(date.getFullYear() + number); break;
            case "m": date.setMonth(date.getMonth() + number); break;
            case "d": date.setDate(date.getDate() + number); break;
            case "w": date.setDate(date.getDate() + 7 * number); break;
            case "h": date.setHours(date.getHours() + number); break;
            case "n": date.setMinutes(date.getMinutes() + number); break;
            case "s": date.setSeconds(date.getSeconds() + number); break;
            case "l": date.setMilliseconds(date.getMilliseconds() + number); break;
        }
        return date;
    }
}
function getHM(date)
{
    var hour =date.getHours();
    var minute= date.getMinutes();
    var ret= (hour>9?hour:"0"+hour)+":"+(minute>9?minute:"0"+minute) ;
    return ret;
}
$(document).ready(function() {
    //debugger;
    var DATA_FEED_URL = "php/datafeed.php";
    var arrT = [];
    var tt = "{0}:{1}";
    for (var i = 0; i < 24; i++) {
        arrT.push({ text: StrFormat(tt, [i >= 10 ? i : "0" + i, "00"]) }, { text: StrFormat(tt, [i >= 10 ? i : "0" + i, "30"]) });
    }
    $("#timezone").val(new Date().getTimezoneOffset()/60 * -1);
    $("#stparttime").dropdown({
        dropheight: 200,
        dropwidth:60,
        selectedchange: function(t) {
            if(t==null){return false;}
            var sd= $("#stpartdate").val();
            var st=t.text;// $("#stparttime").val();
            var ed= $("#etpartdate").val();
            var et= $("#etparttime").val();
            var result=checkStEt(sd,ed,st,et);                  
            if(result)
            {alert("開始日期不能大於結束日期");return false;}
            else
            {
                return true;
            }
        },
        items: arrT
    });
    $("#etparttime").dropdown({
        dropheight: 200,
        dropwidth:60,
        selectedchange: function(t) {
            if(t==null){return false;}
            var sd= $("#stpartdate").val();
            var st= $("#stparttime").val();
            var ed=$("#etpartdate").val();
            var et= t.text;//$("#etparttime").val();
            
            var result=checkStEt(sd,ed,st,et);                  
            if(result)
            {alert("結束日期不能小於開始日期");return false;}
            else
            {return true;}
        },
        items: arrT
    });
    var check = $("#IsAllDayEvent").click(function(e) {
        if (this.checked) {
            $("#stparttime").val("00:00").hide();
            $("#etparttime").val("00:00").hide();
                    
        }
        else {
            var d = new Date();
            var p = 60 - d.getMinutes();
            if (p > 30) p = p - 30;
            d = DateAdd("n", p, d);
            $("#stparttime").val(getHM(d)).show();
            $("#etparttime").val(getHM(DateAdd("h", 1, d))).show();
        }
    });
    if (check[0].checked) {
        $("#stparttime").val("00:00").hide();
        $("#etparttime").val("00:00").hide();
    }
    $("#Savebtn").click(function() { 
        //                jace 2011826 start
        var des=checkDescriptionValid();
        if(des!="")
        {
            alert(des);

            return; 
        }
        if($("#Subject").val()=="")
        {
            alert("請輸入［事件名稱］");
            return;   
        }
        if($("#slctcity").val()==0||$("#slcteventtype").val()==0||$("#slctvenue").val()==0)
        {
            alert("請選擇[城市/類型/場地]後再保存");
            return;
        }
            
        var options = {
            //dataType: 'xml',
            success: function(data)
        {
            var tstart=data.indexOf("{");
            var tstop=data.indexOf("}")+1;
            var json_data=data.substring(tstart,tstop);
            //alert(json_data); 
            var jdata;
            var strJson="jdata="+json_data+";"
            //alert(data);
            eval(strJson); 
            //eval('jdata={"IsSuccess":true,"Msg":"Succefully"};');
            //alert(jdata.Msg); 
            //alert("add success");//date->msg
            //CloseModelWindow();
            if (jdata.IsSuccess) {
                alert(jdata.Msg); 
                CloseModelWindow(null,true); 
                                
            }
            else {
                alert("產生錯誤.\r\n" + jdata.Msg);
            }
        } 
        };    
        $("#fmEdit").ajaxSubmit(options);
        //                jace 2011826 end                
    });
            
    $("#Closebtn").click(function() { CloseModelWindow(); });
    $("#Deletebtn").click(function() {
        if (confirm("確定刪除該日程嗎？")) {  
            //var param = [{ "name": "calendarId", value: 8}];
            var param = [{ "name": "calendarId", value: <?php echo isset($event) ? $event->eid : "X"; ?>}];
                    
            $.post(DATA_FEED_URL + "?method=remove",
            param,
            function(data){
                if (data.IsSuccess) {
                    alert(data.Msg); 
                    CloseModelWindow(null,true);                            
                }
                else {
                    alert("產生錯誤.\r\n" + data.Msg);
                }
            }
            ,"json");
        }
    });
                   
    //$("#stpartdate,#etpartdate").datepicker({ picker: "<button class='calpick'></button>"});    
    $("#stpartdate").datepicker({
        picker: "<button class='calpick'></button>"
        ,onReturn:function(d){
            if(d==null)
            {return;}
            var sd=(d.getMonth()+1) +"/"+d.getDate()+"/"+d.getFullYear();
            var check_allday = $("#IsAllDayEvent");
            //alert(sd);
            var st= $("#stparttime").val();
            var ed= $("#etpartdate").val();
            var et= $("#etparttime").val();
            if(st=="")
                {$("#stparttime").val("00:00");
//                    if (check_allday[0].checked)
//                        { $("#stparttime").val("00:00");}
//                    else
//                        { $("#stparttime").val("23:59");}
                   
                }
            if(et=="")
                {
//                    $("#etparttime").val("00:00");
                    if (check_allday[0].checked)
                        { $("#etparttime").val("00:00");}
                    else
                        { $("#etparttime").val("23:59");}
                }
            if(ed=="")
                {$("#etpartdate").val(sd);}
            var result=checkStEt(sd,ed,st,et);                  
            if(result)
            {alert("開始日期不能大於結束日期");}
            else
            {
                $("#stpartdate").val(sd);
            }
        }
    });  
                    
    $("#etpartdate").datepicker({
        picker: "<button class='calpick'></button>"
        ,onReturn:function(d){
            if(d==null)
            {return;}
            var sd= $("#stpartdate").val();
            var st= $("#stparttime").val();
            var ed=(d.getMonth()+1)+"/"+d.getDate()+"/"+d.getFullYear();
            var et= $("#etparttime").val();
            var check_allday = $("#IsAllDayEvent");
            if(st=="")
                {$("#stparttime").val("00:00");
//                    if (check_allday[0].checked)
//                        { $("#stparttime").val("00:00");}
//                    else
//                        { $("#stparttime").val("23:59");}
                   
                }
            if(et=="")
                {
//                    $("#etparttime").val("00:00");
                    if (check_allday[0].checked)
                        { $("#etparttime").val("00:00");}
                    else
                        { $("#etparttime").val("23:59");}
                }
            if(sd=="")
                {$("#stpartdate").val(ed);$("#stparttime").val("00:00");}
            var result=checkStEt(sd,ed,st,et);                  
            if(result)
            {alert("結束日期不能小於開始日期");}
            else
            {$("#etpartdate").val(ed);}
                           
        }
        
    });
      
    var cv =$("#colorvalue").val() ;
    if(cv=="")
    {
        cv="-1";
    }
    $("#calendarcolor").colorselect({ title: "Color", index: cv, hiddenid: "ColorValue" });
    //to define parameters of ajaxform
    var options = {
        beforeSubmit: function() {
            return true;
        },
        dataType: "json",
        success: function(data) {
            alert(data.Msg);
            if (data.IsSuccess) {
                CloseModelWindow(null,true);  
            }
        }
    };
    $.validator.addMethod("date", function(value, element) {                             
        var arrs = value.split(i18n.datepicker.dateformat.separator);
        var year = arrs[i18n.datepicker.dateformat.year_index];
        var month = arrs[i18n.datepicker.dateformat.month_index];
        var day = arrs[i18n.datepicker.dateformat.day_index];
        var standvalue = [year,month,day].join("-");
        return this.optional(element) || /^(?:(?:1[6-9]|[2-9]\d)?\d{2}[\/\-\.](?:0?[1,3-9]|1[0-2])[\/\-\.](?:29|30))(?: (?:0?\d|1\d|2[0-3])\:(?:0?\d|[1-5]\d)\:(?:0?\d|[1-5]\d)(?: \d{1,3})?)?$|^(?:(?:1[6-9]|[2-9]\d)?\d{2}[\/\-\.](?:0?[1,3,5,7,8]|1[02])[\/\-\.]31)(?: (?:0?\d|1\d|2[0-3])\:(?:0?\d|[1-5]\d)\:(?:0?\d|[1-5]\d)(?: \d{1,3})?)?$|^(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])[\/\-\.]0?2[\/\-\.]29)(?: (?:0?\d|1\d|2[0-3])\:(?:0?\d|[1-5]\d)\:(?:0?\d|[1-5]\d)(?: \d{1,3})?)?$|^(?:(?:16|[2468][048]|[3579][26])00[\/\-\.]0?2[\/\-\.]29)(?: (?:0?\d|1\d|2[0-3])\:(?:0?\d|[1-5]\d)\:(?:0?\d|[1-5]\d)(?: \d{1,3})?)?$|^(?:(?:1[6-9]|[2-9]\d)?\d{2}[\/\-\.](?:0?[1-9]|1[0-2])[\/\-\.](?:0?[1-9]|1\d|2[0-8]))(?: (?:0?\d|1\d|2[0-3])\:(?:0?\d|[1-5]\d)\:(?:0?\d|[1-5]\d)(?:\d{1,3})?)?$/.test(standvalue);
    }, "Invalid date format");
    $.validator.addMethod("time", function(value, element) {
        return this.optional(element) || /^([0-1]?[0-9]|2[0-3]):([0-5][0-9])$/.test(value);
    }, "Invalid time format");
    $.validator.addMethod("safe", function(value, element) {
        return this.optional(element) || /^[^$\<\>]+$/.test(value);
    }, "$<> not allowed");
    $("#fmEdit").validate({
        submitHandler: function(form) { $("#fmEdit").ajaxSubmit(options); },
        errorElement: "div",
        errorClass: "cusErrorPanel",
        errorPlacement: function(error, element) {
            showerror(error, element);
        }
    });
    function showerror(error, target) {
        var pos = target.position();
        var height = target.height();
        var newpos = { left: pos.left, top: pos.top + height + 2 }
        var form = $("#fmEdit");             
        error.appendTo(form).css(newpos);
    }
});
        
$(document).ready(function() {
       
    //alert("starting loading......");
    var DATA_FEED_URL = "php/datafeed.php";
       
    //feed the event types to page
    if($("#slcteventtype").find("option").length == 1)
    {  
        $.post(
        DATA_FEED_URL + "?method=getAllEventTypes",
        function (data){ 
            var associatedEventType = <?php
if (isset($event->etid)) {
    echo $event->etid;
} else {
    echo 0;
}
?>;
$.each(data.types,function(index, value){                        
    $("#slcteventtype").append('<option value = ' + value[0] + '>' + value[1] + '</option>'); 
    if(eval(value[0]) == associatedEventType){$("#slcteventtype").val(associatedEventType);}
});  
},
"json");
}
          
//feed the city to page
var associatedCity = <?php
if (isset($event->cid)) {
    echo $event->cid;
} else {
    echo 0;
}
?>; 
if($("#slctcity").find("option").length == 1)
{
                                           
$.post(DATA_FEED_URL + "?method=getAllCities",
function (data){ 
$.each(data.cities,function(index, value){                                            
    $("#slctcity").append('<option value = ' + value[0] +'>'+ value[1]+ '</option>');
    // eval :string convert to number
    if(eval(value[0]) == associatedCity) {$("#slctcity").val(associatedCity);}                       
});  
},
"json");
} 
          

if($("#slctvenue").find("option").length == 1)
{
var associatedVenue = <?php
if (isset($event->vid)) {
    echo $event->vid;
} else {
    echo 0;
}
?>;                        
$.post(DATA_FEED_URL + "?method=getVenuesByCityId",
//{cityid: $("#slctcity").val()},
{cityid:associatedCity},
function (data){
$.each(data.venues,function(index, value){                                            
    $("#slctvenue").append('<option value = ' + value[0] +'>'+ value[1]+ '</option>');
    // eval :string convert to number
    if(eval(value[0]) == associatedVenue) {$("#slctvenue").val(associatedVenue);}                       
});  
},
"json");
} 
          
          
$("#slctcity").change(function(e)
{
//ajax call to get the venues assciation with city
//var DATA_FEED_URL = "php/datafeed.php";
$.post(DATA_FEED_URL + "?method=getVenuesByCityId",
{cityid: $("#slctcity").val()},
function (data){
                    
//alert(data.error);
                    
if(data.error == null)
{
                       
    var selectcityval = $("#slctcity").find("option:selected").val();
                       
                       
    $("#slctvenue")
    //.find('option')
    //.remove()
    //.end()
    .empty();
                                             
    if(selectcityval != 0)
    {
        var selectcitytext = $("#slctcity").find("option:selected").text();
        $("#slctvenue")
        .append('<option value="0">所有'+selectcitytext+'場地</option>');
        //alert(selectcitytext);
    }
    else
    {
        $("#slctvenue")
        .append('<option value="0">所有場地</option>');    
    }
                       
    $.each(data.venues,function(index, value){
                       
        $("#slctvenue").append('<option value = ' 
            + value[0] 
            +'>'
            + value[1]
            + '</option>');
                                    
    });
                       
}
},
"json");
                
});
            
            
$("#slctvenue").change(function(e)
{
$.post(DATA_FEED_URL + "?method=getVenueByVenueId",
{venueid: $("#slctvenue").val()},
function (data){
                    
//alert(data.error);
                    
if(data.error == null)
{                     
    $.each(data.venue,function(index, value){
        $("#iptvaddress").val(value[4]);
        $("#iptvtelephones").val(value[2]);
        $("#iptvcontact").val(value[5]);
        $("#iptvurls").val(value[3]);
                                    
    });                       
}
},
"json");
                
});
  
}); 
         
        
        
            </script>      
            <style type="text/css">     
                .calpick     {        
                    width:16px;   
                    height:16px;     
                    border:none;        
                    cursor:pointer;        
                    background:url("sample-css/cal.gif") no-repeat center 2px;        
                    margin-left:-22px;    
                }      
            </style>
    </head>
    <body>    
        <div>      
            <div class="toolBotton">           
                <a id="Savebtn" class="imgbtn" href="javascript:void(0);">                
                    <span class="Save"  title="Save the calendar"><!--Save-->保存(<u>S</u>)
                    </span>          
                </a>                           
                <?php if (isset($event)) { ?>
                    <a id="Deletebtn" class="imgbtn" href="javascript:void(0);">                    
                        <span class="Delete" title="Cancel the calendar"><!--Delete-->刪除(<u>D</u>)
                        </span>                
                    </a>             
                <?php } ?>            
                <a id="Closebtn" class="imgbtn" href="javascript:void(0);">                
                    <span class="Close" title="Close the window" ><!--Close-->關閉
                    </span></a>            
                </a>        
            </div>                  
            <div style="clear: both">         
            </div>        
            <div class="infocontainer">            
                <form action="php/datafeed.php?method=adddetails<?php echo isset($event) ? "&id=" . $event->eid : ""; ?>" class="fform" id="fmEdit" method="post">                 
                    <label>                    
                        <span>                        *事件名稱:              
                        </span>                    
                        <!--            <div id="calendarcolor">
                                    </div>-->
                        <input MaxLength="200" class="required safe" id="Subject" name="Subject" style="width:85%;" type="text" value="<?php echo isset($event) ? $event->subject : "" ?>" />                     
                        <input id="ColorValue" name="ColorValue" type="hidden" value="<?php echo isset($event) ? $event->color : "" ?>" />                
                    </label>                 
                    <label>                    
                        <span>*時間:
                        </span>                    
                        <div>  
                            <?php
                            if (isset($event)) {
                                $sarr = explode(" ", php2JsTime(mySql2PhpTime($event->start_time)));
                                $earr = explode(" ", php2JsTime(mySql2PhpTime($event->end_time)));
                            }
                            ?>                    
                            <input MaxLength="10" class="required date" id="stpartdate" name="stpartdate" style="padding-left:2px;width:90px;" type="text" value="<?php echo isset($event) ? $sarr[0] : ""; ?>" />                       
                            <input MaxLength="5" class="required time" id="stparttime" name="stparttime" style="width:40px;" type="text" value="<?php echo isset($event) ? $sarr[1] : ""; ?>" />至                       
                            <input MaxLength="10" class="required date" id="etpartdate" name="etpartdate" style="padding-left:2px;width:90px;" type="text" value="<?php echo isset($event) ? $earr[0] : ""; ?>" />                       
                            <input MaxLength="50" class="required time" id="etparttime" name="etparttime" style="width:40px;" type="text" value="<?php echo isset($event) ? $earr[1] : ""; ?>" />                                            
                            <label class="checkp"> 
                                <input id="IsAllDayEvent" name="IsAllDayEvent" type="checkbox" value="1" <?php
                            if (isset($event) && $event->is_allday_event != 0) {
                                echo "checked";
                            }
                            ?>/>          全天事件<!--All Day Event-->                      
                            </label>                    
                        </div>                
                    </label> 

                    <label>                    
                        <span>                        *城市:
                        </span>  

                        <?php
                        echo '<select name = "slctcity" id = "slctcity">';
                        echo '<option value= "0" >所有城市</option>';
                        // foreach($cities as $city){
                        //   //echo "<script  type='text/javascript'> alert ('test".$row['cid']."')</script>";
                        echo '</select>';
                        ?>

                    </label>
                    <label>                    
                        <span>                        *類型:
                        </span>  
                        <?php
                        echo '<select id = "slcteventtype" name = "Type">';
                        echo '<option value= "0" >所有類型</option>';
                        echo '</select>';
                        ?> 
                    </label>

                    <label>                    
                        <span>                        *場地:
                        </span>  
                        <?php
                        echo '<select name = "Venue" id ="slctvenue" >';
                        echo '<option value= "0" >所有場地</option>';
                        echo '</select>';
                        ?> 
                    </label>
                    <label>                    
                        <span>                       所屬節目:
                        </span> 

                        <input MaxLength="100" id="Festival" name="Festival" style="width:95%;" type="text" value="<?php echo isset($event) ? $event->festival : ""; ?>" />                 
                    </label>                 


                    <label>                    
                        <span>                        地址:
                        </span>
                         <!--修改地址<input type="checkbox" id="ischangevaddressid" name="ischangevaddress"  value ="false" />  -->         
                        <input MaxLength="50" id="iptvaddress" name="V_address" style="width:95%;" type="text" readonly="readonly" value="<?php echo isset($event) ? $event->address_zh_hk : ""; ?>" />                 
                    </label>


                    <label>                    
                        <span>                        電話:
                        </span>                    
                        <input MaxLength="20" id="iptvtelephones" name="V_telephones" style="width:95%;" type="text" readonly="readonly" value="<?php echo isset($event) ? $event->telephones : ""; ?>" />                 
                    </label> 

                    <label>                    
                        <span>                        連絡人:
                        </span>                    
                        <input MaxLength="20" id="iptvcontact" name="V_contact" style="width:95%;" type="text" readonly="readonly" value="<?php echo isset($event) ? $event->contact_person : ""; ?>" />                 
                    </label>

                    <label>                    
                        <span>                        場地網站:
                        </span>                    
                        <input MaxLength="50" id="iptvurls" name="V_urls" style="width:95%;" type="text" readonly="readonly" value="<?php echo isset($event) ? $event->urls : ""; ?>" />                 
                    </label>

                    <label>                    AMCNN相關介绍:
                        </span>                    
                        <input MaxLength="50" id="iptvurls" name="DetailUrl" style="width:95%;" type="text"  value="<?php echo isset($event) ? $event->detail_url : ""; ?>" />                 
                    </label>  

                    <?php
                    if ($login_admin_id) {
                        echo '<label>';
                        echo ' <span>                        顯示廣告:';
                        echo ' </span>';
                        if (isset($event) && $event->commercial_control == 0) {
                            echo '  <input  id="ipcommercialcontrolno" name="CommercialControl" " type="radio" value = "' . $event->commercial_control . '" checked/>不顯示';
                        } else {
                            echo '  <input  id="ipcommercialcontrolno" name="CommercialControl" " type="radio" value = "0" checked/>不顯示';
                        }
                        echo ' </label>';

                        echo '<label>';
                        if (isset($event) && $event->commercial_control == 1) {
                            echo '  <input  id="ipcommercialcontrolno" name="CommercialControl" " type="radio" value = "' . $event->commercial_control . '" checked/>顯示';
                        } else {
                            echo '  <input  id="ipcommercialcontrolyes" name="CommercialControl" " type="radio" value = "1"/>顯示';
                        }
                        echo ' </label>';
                        
                                                echo '<label>';
                        echo ' <span>                        顯示主視窗:';
                        echo ' </span>';
                        if (isset($event) && $event->click_window_control == 0) {
                            echo '  <input  id="ipclickwindowcontrolno" name="ClickWindowControl" " type="radio" value = "' . $event->click_window_control . '" checked/>不顯示';
                        } else {
                            echo '  <input  id="ipclickwindowcontrolno" name="ClickWindowControl" " type="radio" value = "0" checked/>不顯示';
                        }
                        echo ' </label>';

                        echo '<label>';
                        if (isset($event) && $event->click_window_control == 1) {
                            echo '  <input  id="ipclickwindowcontrolno" name="ClickWindowControl" " type="radio" value = "' . $event->click_window_control . '" checked/>顯示';
                        } else {
                            echo '  <input  id="ipclickwindowcontrolyes" name="ClickWindowControl" " type="radio" value = "1"/>顯示';
                        }
                        echo ' </label>';
                        
                        
                        echo '<label>';
                        echo ' <span>                        相關小圖片:';
                        echo ' </span>';
                        echo '  <input MaxLength="150" id="iptvpicturepathsmall" name="V_picture_small" style="width:95%;" type="file"/> ';
                        echo ' </label>';
                        echo '    <label>  ';
                        echo '   <span>                        相關中圖片:';
                        echo '   </span>';
                        echo '  <input MaxLength="150" id="iptvpicturepathmiddle" name="V_picture_middle" style="width:95%;" type="file"/> ';
                        echo ' </label>';
                        echo ' <label> ';
                        echo '   <span>                        相關主視窗大圖片:';
                        echo '   </span>  ';
                        echo '   <input MaxLength="150" id="iptvpicturepathbig" name="V_picture_big" style="width:95%;" type="file"/> ';
                        echo ' </label>';
                        echo '    <label>  ';
                        echo '   <span>                        Flash文檔:';
                        echo '  </span>        ';
                        echo '  <input MaxLength="150" id="iptvflash" name="V_flash" style="width:95%;" type="file"/>  ';
                        echo ' </label>';
                    }
                    ?>
                    <input type="hidden" id="iptvpicturepaths" name="iptvpicturepaths" value="<?php echo isset($event) ? $event->picture_paths : ""; ?>"></input>
                    <input type="hidden" id="iptvstarttime" name="iptvstarttime" value="<?php echo isset($event) ? $event->start_time : ""; ?>"></input>
                    <input type="hidden" id="iptvendtime" name="iptvendtime" value="<?php echo isset($event) ? $event->end_time : ""; ?>"></input>

                    <label>
                        <span>                        事件描述:
                        </span>                    
                        <textarea cols="10" id="Description" name="Description" rows="2" style="width:95%; height:70px"><?php echo isset($event) ? $event->description : ""; ?></textarea>                
                    </label> 

                    <input id="timezone" name="timezone" type="hidden" value="" /> 
                    <input id="IsVenueChanged" name="IsVenueChanged" type="hidden" value="" /> 

                </form>         
            </div>         
        </div>
    </body>
</html>
